const CHANGE_IMAGE = 'CHANGE_IMAGE'; //更改图文信息
const CHANGE_CAPACITY = 'CHANGE_CAPACITY'; //更改容量信息
const ADD_PRODUCT = 'ADD_PRODUCT'; //新增商品
const REMOVE_PRODUCT = 'REMOVE_PRODUCT'; //删除商品

export default {
  [CHANGE_IMAGE](state, {item, key}) {
    state.iPhone6S.activeStyleUrl = item;
    state.iPhone6S.activeStyle = key;
  },
  [CHANGE_CAPACITY](state, {item, key}) {
    state.iPhone6S.price = item;
    state.iPhone6S.isSelected = true;
    state.iPhone6S.activeStorage = key;
    console.log(key)
  },
  [ADD_PRODUCT](state) {
    const apparent = state.iPhone6S.activeStyle == "" ? "银色" : state.iPhone6S.activeStyle;
    const arr = {
      "name": state.iPhone6S.name,
      "price": state.iPhone6S.price,
      "apparent": apparent,
      "capacity": state.iPhone6S.activeStorage,
      "count": 1
    }
    console.log(arr)
    state.cart.push(arr)
  },
  [REMOVE_PRODUCT](state,index){
    state.cart.splice(index, 1)
  }

}
